/**
 * Created by hcadmin on 16/6/14.
 */
var Action = require("../apiaction");
var DataProxy = require("data-proxy");
var httpconf=require('../../node_modules/data-proxy/lib/httpconf.js');
var Utility = require("../Utility/utility.js");

exports.userRouter = function(router){

    //咨询分类管理
    router.all('/consultationClassification',function(req,res){
        res.render('ct/courseManagement/consultationClassification', {
            layout: 'ct/layout-ct',
            active: 'consultationClassification',
            jscript: 'ct/courseManagement/consultationClassification'
        })
    });

    //咨询文章管理
    router.all('/consultationArticle',function(req,res){
        res.render('ct/courseManagement/consultationArticle', {
            layout: 'ct/layout-ct',
            active: 'consultationArticle',
            jscript: 'ct/courseManagement/consultationArticle'
        })
    });

    //资料库管理
    router.all('/databaseManagement',function(req,res){
        res.render('ct/courseManagement/databaseManagement', {
            layout: 'ct/layout-ct',
            active: 'databaseManagement',
            jscript: 'ct/courseManagement/databaseManagement'
        })
    });


    //老师管理
    router.all('/teacherManagement',function(req,res){
        res.render('ct/userManagement/teacherManagement', {
            layout: 'ct/layout-ct',
            active: 'teacherManagement',
            jscript: 'ct/userManagement/teacherManagement'
        })
    });

    //总裁管理
    router.all('/ceoManagement',function(req,res){
        res.render('ct/userManagement/ceoManagement', {
            layout: 'ct/layout-ct',
            active: 'ceoManagement',
            jscript: 'ct/userManagement/ceoManagement'
        })
    });

    //普通用户管理
    router.all('/ordinaryUsersManagement',function(req,res){
        res.render('ct/userManagement/ordinaryUsersManagement', {
            layout: 'ct/layout-ct',
            active: 'ordinaryUsersManagement',
            jscript: 'ct/userManagement/ordinaryUsersManagement'
        })
    });


    //小组管理
    router.all('/groupManagement',function(req,res){
        res.render('ct/groupManagement/groupManagement', {
            layout: 'ct/layout-ct',
            active: 'groupManagement',
            jscript: 'ct/groupManagement/groupManagement'
        })
    });

    //新增成员
    router.all('/addNewMumber',function(req,res){
        var team_id = req.param("team_id");

        var page = 1;
        var rows = 100;
        var listType = "0";
        var keyword = "";

        var params = {method:'GET',page:page,rows:rows,listType:listType,keyword:keyword};
        Action.send(req, res,"/users/list",params,function(res,data) {
            var json_normal = JSON.parse(data);
            params.listType = "1";
            Action.send(req, res, "/users/list", params, function (res, data) {
                var json_teacher = JSON.parse(data);
                params.listType = "2";
                Action.send(req, res, "/users/list", params, function (res, data) {
                    var json_leader = JSON.parse(data);
                    res.render('ct/groupManagement/addNewMumber', {
                        layout: 'ct/layout-ct',
                        active: 'groupManagement',
                        jscript: 'ct/groupManagement/addNewMumber',
                        team_id: team_id,
                        data_normal: json_normal.data.rows,
                        data_teacher: json_teacher.data.rows,
                        data_leader: json_leader.data.rows,
                    })
                });
            });
        });
    });

    //考核管理
    router.all('/checkManagement',function(req,res){

        res.render('ct/checkManagement/checkManagement', {
            layout: 'ct/layout-ct',
            active: 'checkManagement',
            jscript: 'ct/checkManagement/checkManagement'
        })
    });

    //培训课程管理
    router.all('/trainingCourseManagement',function(req,res){
        res.render('ct/actionManagement/trainingCourseManagement', {
            layout: 'ct/layout-ct',
            active: 'trainingCourseManagement',
            jscript: 'ct/actionManagement/trainingCourseManagement'
        })
    });

    //报告管理
    router.all('/presentationManagement',function(req,res){
        var train_id = req.param("train_id");
        res.render('ct/actionManagement/presentationManagement', {
            layout: 'ct/layout-ct',
            active: 'presentationManagement',
            jscript: 'ct/actionManagement/presentationManagement',
            train_id:train_id
        })
    });


    //学习汇总
    router.all('/learningSummary',function(req,res){
        res.render('ct/LearningSummary/LearningSummary', {
            layout: 'ct/layout-ct',
            active: 'learningSummary',
            jscript: 'ct/LearningSummary/LearningSummary'
        })
    });

    //聊天管理
    router.all('/chatManagement',function(req,res){
        var host = req.param("host")
        res.render('ct/chatManagement/chatManagement', {
            layout: 'ct/layout-ct',
            active: 'chatManagement',
            jscript: 'ct/chatManagement/chatManagement',
        })
    });

    //试卷
    router.all('/checkMaths',function(req,res){
        var paper_id=req.param('paper_id')
        res.render('ct/checkManagement/checkMaths', {
            layout: 'ct/layout-ct',
            active: 'checkManagement',
            jscript: 'ct/checkManagement/checkMaths',
            paper_id:paper_id
        })
    });

    //培训题库
    router.all('/trainQuestions',function(req,res){
        var train_id=req.param('train_id')
        var train_name=req.param('train_name')
        res.render('ct/actionManagement/trainQuestions', {
            layout: 'ct/layout-ct',
            active: 'trainingCourseManagement',
            jscript: 'ct/actionManagement/trainQuestions',
            train_id:train_id,
            train_name:train_name
        })
    });

    //报告管理
    router.all('/reportManagement',function(req,res){
        var train_id=req.param('train_id');
        Action.send(req,res,"/users/list",{page:1,rows:100,method:'GET',listType:'0',keyword:''},function(res,data){
            var json =JSON.parse(data);
            res.render('ct/actionManagement/reportManagement', {
                layout: 'ct/layout-ct',
                active: 'presentationManagement',
                jscript: 'ct/actionManagement/reportManagement',
                train_id:train_id,
                user_data:json.data.rows
            })
        })

    });
    
    //评论管理
    router.all('/commentManagement',function(req,res){
        res.render('ct/commentManagement/commentManagement', {
            layout: 'ct/layout-ct',
            active: 'commentManagement',
            jscript: 'ct/commentManagement/commentManagement',
        })
    });

    //小组讨论
    router.all('/panelDiscussion',function(req,res){
        Action.send(req, res,"teams/list",{method:"GET"},function(res,data){
            var teamsList=JSON.parse(data);
            Action.send(req, res,"trains/list",{method:"GET",listType:0},function(res,data){
                var trainsList=JSON.parse(data);
                    res.render('ct/groupManagement/panelDiscussion', {
                        layout: 'ct/layout-ct',
                        active: 'panelDiscussion',
                        jscript: 'ct/groupManagement/panelDiscussion',
                        teamsList:teamsList.data,
                        trainsList:trainsList.data.rows,
                    })
            });
        });
    });

//轮播图管理
    router.all('/banner',function(req,res){
        res.render('ct/banner/banner', {
            layout: 'ct/layout-ct',
            active: 'banner',
            jscript: 'ct/banner/banner',
        })
    });

};

